package com.radiant.data.entity.converter;

import java.util.Date;

import org.apache.commons.beanutils.Converter;

public class DateConverter implements Converter {

	public Object convert(Class type, Object value) {
		
		if (type == String.class) {
			Date date = (Date) value;
			long time = date.getTime();
			return Long.toString(time);
		} else if (type == Date.class) {
			String dateString = (String) value;
			Date date = new Date(Long.valueOf(dateString));
			return date;
		} else {
			return value;
		}
	}

}
